home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / fd / lseek.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  676b  |  38 lines

  1.  
  2. /*
  3.  *  LSEEK.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <clib/dos_protos.h>
  11. #include <stdio.h>
  12. #include <fcntl.h>
  13. #include <ioctl.h>
  14. #include <errno.h>
  15.  
  16. long
  17. lseek(fd, offset, whence)
  18. int fd;
  19. long offset;
  20. int whence;
  21. {
  22.     _IOFDS *d;
  23.     int n = -1;
  24.  
  25.     if (d = __getfh(fd)) {
  26.     if (d->fd_Exec)
  27.         return((*d->fd_Exec)(d->fd_Fh, IOC_SEEK, (void *)offset, (void *)whence));
  28.     n = Seek(d->fd_Fh, offset, whence-1);
  29.     if (n >= 0) {
  30.         if (offset || whence != 1)
  31.         n = Seek(d->fd_Fh, 0L, 0);
  32.         return(n);
  33.     }
  34.     }
  35.     return(n);
  36. }
  37.  
  38.